/*
 * palindrom.c
 *
 *  Created on: Feb 20, 2013
 *      Author: alvaroperedasancho
 */
#include <stdio.h>
#include <stdlib.h>
#include "include/palindrom.h"

void palindrome() {
	char sentence [MAX_LENGTH];
	int palin;

	askUser(sentence);
	palin = isPalindrome(sentence);

	printf("%s is%sa palindrome", sentence, palin? " " : " not ");
}

void askUser(char * sent) {
	printf ("Intro a sentence: ");
	scanf("%s", sent);
}

int isPalindrome(char * sen) {
	int l, i;

	l = strlen(sen);
	printf("length: %d\n", l);

	for (i = 0; i < l/2; i++) {
		if (sen[i] != sen[l-(i+1)]) {
			return 0;
		}
	}

	return 1;
}

